import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bmfmap_example/tool/tool.dart';
import 'package:flutter_pickers/pickers.dart';

class familyText extends StatefulWidget {
  const familyText({Key key}) : super(key: key);

  @override
  _familyTextState createState() => _familyTextState();
}

class _familyTextState extends State<familyText> {

  var logoid = 1;
  var name;
  var birthday;
  var age;
  var height;
  var weight;
  var safeDistance;
  
  

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: Text(
          '添加家人',
          style: TextStyle(
            fontSize: 16,
            color: Color.fromRGBO(72, 72, 72, 1),
            fontWeight: FontWeight.bold,
          ),
        ),
        backgroundColor: Colors.white,
        // backgroundColor: Color.fromRGBO(252, 252, 189, 1),
        elevation: 0,
        leading: InkWell(
          onTap: () {
            Navigator.pop(context);
          },
          child: Icon(
            Icons.keyboard_arrow_left,
            color: Color.fromRGBO(72, 72, 72, 1),
          ),
        ),
      ),
      body: Container(
        child: Stack(
          children: [
            // Center(child: Positioned(child: Image.asset('images/家.png'))),
            Center(
              child: Column(
                children: [
                  Padding(
                    padding: const EdgeInsets.only(top: 40),
                    child: Container(
                      child: Stack(
                        children: [
                          Positioned(
                            left: 10,
                            child: Container(
                              width: 88,
                              height: 88,
                              decoration: new BoxDecoration(
                                color: Color.fromRGBO(255, 205, 216, 1),
                                borderRadius: new BorderRadius.circular((50.0)),
                              ),
                              child: Image.asset(Tool.getportrait(logoid)),
                            ),
                          ),
                          Positioned(
                            top: 50,
                            left: 70,
                            child: InkWell(
                              onTap: () {
                                showDialog<int>(
                                  
                                  context: context,
                                  barrierDismissible: false,
                                  builder: (BuildContext context) {
                                    int select ;
                                    return new AlertDialog(
                                      title: new Text('头像'),
                                      content: new SingleChildScrollView(
                                        child: new Container(
                                            height: 110,
                                            // width: 400,
                                            child: Column(
                                              children: [
                                                Row(
                                                  mainAxisAlignment:
                                                      MainAxisAlignment
                                                          .spaceBetween,
                                                  children: [
                                                    InkWell(
                                                      onTap: (){
                                                        select = 1;
                                                        Navigator.of(context).pop(select);
                                                      },
                                                      child: new Image.asset(
                                                        Tool.getportrait(1),
                                                        width: 48,
                                                      ),
                                                    ),
                                                    InkWell(
                                                      onTap: (){
                                                        select = 2;
                                                        Navigator.of(context).pop(select);
                                                      },
                                                      child: new Image.asset(
                                                        Tool.getportrait(2),
                                                        width: 48,
                                                      ),
                                                    ),
                                                    InkWell(
                                                      onTap: (){
                                                        select = 3;
                                                        Navigator.of(context).pop(select);
                                                      },
                                                      child: new Image.asset(
                                                        Tool.getportrait(3),
                                                        width: 48,
                                                      ),
                                                    ),
                                                    InkWell(
                                                      onTap: (){
                                                        select = 4;
                                                        Navigator.of(context).pop(select);
                                                      },
                                                      child: new Image.asset(
                                                        Tool.getportrait(4),
                                                        width: 48,
                                                      ),
                                                    ),
                                                  ],
                                                ),
                                                Padding(
                                                  padding:
                                                      const EdgeInsets.only(
                                                          top: 10),
                                                  child: Row(
                                                    mainAxisAlignment:
                                                        MainAxisAlignment
                                                            .spaceBetween,
                                                    children: [
                                                      InkWell(
                                                        onTap: (){
                                                        select = 5;
                                                        Navigator.of(context).pop(select);
                                                      },
                                                        child: new Image.asset(
                                                          Tool.getportrait(5),
                                                          width: 48,
                                                        ),
                                                      ),
                                                      InkWell(
                                                        onTap: (){
                                                        select = 6;
                                                        Navigator.of(context).pop(select);
                                                      },
                                                        child: new Image.asset(
                                                          Tool.getportrait(6),
                                                          width: 48,
                                                        ),
                                                      ),
                                                      InkWell(
                                                        onTap: (){
                                                        select = 7;
                                                        Navigator.of(context).pop(select);
                                                      },
                                                        child: new Image.asset(
                                                          Tool.getportrait(7),
                                                          width: 48,
                                                        ),
                                                      ),
                                                      InkWell(
                                                        onTap: (){
                                                        select = 8;
                                                        Navigator.of(context).pop(select);
                                                      },
                                                        child: new Image.asset(
                                                         Tool.getportrait(8),
                                                          width: 48,
                                                        ),
                                                      ),
                                                    ],
                                                  ),
                                                ),
                                              ],
                                            )
                                            // children: <Widget>[
                                            //   new Text('内容 2'),
                                            // ],
                                            ),
                                      ),
                                      actions: <Widget>[
                                        new FlatButton(
                                          child: new Text('确定'),
                                          onPressed: () {
                                            Navigator.of(context).pop(select);
                                          },
                                        ),
                                      ],
                                    );
                                  },
                                ).then((val) {
                                  print(val);
                                  if(val!=null)logoid = val;
                                  setState(() {
                                    
                                  });
                                });
                              },
                              child: Container(
                                child: Image.asset('assets/images/common/添加图片.png'),
                                width: 45,
                                height: 45,
                                decoration: new BoxDecoration(
                                  color: Colors.white,
                                  borderRadius:
                                      new BorderRadius.circular((50.0)),
                                ),
                              ),
                            ),
                          ),
                        ],
                      ),
                      width: 120,
                      height: 120,
                      // decoration: new BoxDecoration(
                      //   color: Color.fromRGBO(255, 205, 216, 1),
                      //   borderRadius: new BorderRadius.circular((50.0)),
                      // ),
                    ),
                  ),
                  Padding(
                    padding:
                        const EdgeInsets.only(left: 20, right: 20, bottom: 15),
                    child: TextField(
                      enableInteractiveSelection: false,
                      cursorColor: Color.fromRGBO(116, 208, 217, 1),
                      cursorRadius: Radius.circular(10.0),
                      cursorWidth: 4.0,
                      decoration: InputDecoration(
                        filled: true,
                        fillColor: Color.fromRGBO(242, 242, 242, 0.8),
                        enabledBorder: OutlineInputBorder(
                            /*边角*/
                            borderRadius: BorderRadius.all(
                              Radius.circular(30), //边角为30
                            ),
                            borderSide: BorderSide(
                              color: Color.fromRGBO(1, 1, 1, 0), //边线颜色为黄色
                              width: 3, //边//宽度为5
                            )),

                        focusedBorder: OutlineInputBorder(
                            borderRadius: BorderRadius.all(
                              Radius.circular(30), //边角为30
                            ),
                            borderSide: BorderSide(
                              color: Color.fromRGBO(1, 1, 1, 0), //边线颜色为黄色
                              width: 3, //边//宽度为5
                            )),
                        labelText: "姓名",
                        labelStyle: TextStyle(color: Colors.black38),
                        // helperText: "helperText",
                        // errorText: "errorText",
                        // hintText: "hintText",
                      ),
                    ),
                  ),
                  Padding(
                    padding:
                        const EdgeInsets.only(left: 20, right: 20, bottom: 15),
                    child: InkWell(
                      onTap: () {
                        Pickers.showDatePicker(
                          context,
                          onConfirm: (p) {
                            print(p);
                            birthday = p.year.toString() +
                                '-' +
                                p.month.toString() +
                                '-' +
                                p.day.toString();
                            setState(() {});
                          },
                          // onChanged: (p) => print(p),
                        );
                      },
                      child: Container(
                        width: 500,
                        height: 58,
                        child: Padding(
                          padding: const EdgeInsets.only(top: 15, left: 14),
                          child: Text(
                            birthday == null ? "生日" : birthday,
                            style:
                                TextStyle(color: Colors.black38, fontSize: 16),
                          ),
                        ),
                        // color: Colors.black12,
                        decoration: new BoxDecoration(
                          color: Color.fromRGBO(242, 242, 242, 0.8),
                          borderRadius: new BorderRadius.circular((50.0)),
                        ),
                      ),
                    ),
                    // child: TextField(
                    //   cursorColor: Color.fromRGBO(116, 208, 217, 1),
                    //   cursorRadius: Radius.circular(10.0),
                    //   cursorWidth: 4.0,
                    //   decoration: InputDecoration(
                    //     filled: true,
                    //     fillColor: Color.fromRGBO(242, 242, 242, 0.8),
                    //     enabledBorder: OutlineInputBorder(
                    //         /*边角*/
                    //         borderRadius: BorderRadius.all(
                    //           Radius.circular(30), //边角为30
                    //         ),
                    //         borderSide: BorderSide(
                    //           color: Color.fromRGBO(1, 1, 1, 0), //边线颜色为黄色
                    //           width: 3, //边//宽度为5
                    //         )),

                    //     focusedBorder: OutlineInputBorder(
                    //         borderRadius: BorderRadius.all(
                    //           Radius.circular(30), //边角为30
                    //         ),
                    //         borderSide: BorderSide(
                    //           color: Color.fromRGBO(1, 1, 1, 0), //边线颜色为黄色
                    //           width: 3, //边//宽度为5
                    //         )),
                    //     labelText: "生日",
                    //     labelStyle: TextStyle(color: Colors.black38),
                    //     // helperText: "helperText",
                    //     // errorText: "errorText",
                    //     // hintText: "hintText",
                    //   ),
                    // ),
                  ),
                  Padding(
                    padding:
                        const EdgeInsets.only(left: 20, right: 20, bottom: 15),
                    child: TextField(
                      cursorColor: Color.fromRGBO(116, 208, 217, 1),
                      cursorRadius: Radius.circular(10.0),
                      cursorWidth: 4.0,
                      decoration: InputDecoration(
                        filled: true,
                        fillColor: Color.fromRGBO(242, 242, 242, 0.8),
                        enabledBorder: OutlineInputBorder(
                            /*边角*/
                            borderRadius: BorderRadius.all(
                              Radius.circular(30), //边角为30
                            ),
                            borderSide: BorderSide(
                              color: Color.fromRGBO(1, 1, 1, 0), //边线颜色为黄色
                              width: 3, //边//宽度为5
                            )),

                        focusedBorder: OutlineInputBorder(
                            borderRadius: BorderRadius.all(
                              Radius.circular(30), //边角为30
                            ),
                            borderSide: BorderSide(
                              color: Color.fromRGBO(1, 1, 1, 0), //边线颜色为黄色
                              width: 3, //边//宽度为5
                            )),
                        labelText: "年龄",
                        labelStyle: TextStyle(color: Colors.black38),
                        // helperText: "helperText",
                        // errorText: "errorText",
                        // hintText: "hintText",
                      ),
                    ),
                  ),
                  Padding(
                    padding:
                        const EdgeInsets.only(left: 20, right: 20, bottom: 15),
                    child: TextField(
                      cursorColor: Color.fromRGBO(116, 208, 217, 1),
                      cursorRadius: Radius.circular(10.0),
                      cursorWidth: 4.0,
                      decoration: InputDecoration(
                        filled: true,
                        fillColor: Color.fromRGBO(242, 242, 242, 0.8),
                        enabledBorder: OutlineInputBorder(
                            /*边角*/
                            borderRadius: BorderRadius.all(
                              Radius.circular(30), //边角为30
                            ),
                            borderSide: BorderSide(
                              color: Color.fromRGBO(1, 1, 1, 0), //边线颜色为黄色
                              width: 3, //边//宽度为5
                            )),

                        focusedBorder: OutlineInputBorder(
                            borderRadius: BorderRadius.all(
                              Radius.circular(30), //边角为30
                            ),
                            borderSide: BorderSide(
                              color: Color.fromRGBO(1, 1, 1, 0), //边线颜色为黄色
                              width: 3, //边//宽度为5
                            )),
                        labelText: "身高",
                        labelStyle: TextStyle(color: Colors.black38),
                        // helperText: "helperText",
                        // errorText: "errorText",
                        // hintText: "hintText",
                      ),
                    ),
                  ),
                  Padding(
                    padding:
                        const EdgeInsets.only(left: 20, right: 20, bottom: 15),
                    child: TextField(
                      cursorColor: Color.fromRGBO(116, 208, 217, 1),
                      cursorRadius: Radius.circular(10.0),
                      cursorWidth: 4.0,
                      decoration: InputDecoration(
                        filled: true,
                        fillColor: Color.fromRGBO(242, 242, 242, 0.8),
                        enabledBorder: OutlineInputBorder(
                            /*边角*/
                            borderRadius: BorderRadius.all(
                              Radius.circular(30), //边角为30
                            ),
                            borderSide: BorderSide(
                              color: Color.fromRGBO(1, 1, 1, 0), //边线颜色为黄色
                              width: 3, //边//宽度为5
                            )),

                        focusedBorder: OutlineInputBorder(
                            borderRadius: BorderRadius.all(
                              Radius.circular(30), //边角为30
                            ),
                            borderSide: BorderSide(
                              color: Color.fromRGBO(1, 1, 1, 0), //边线颜色为黄色
                              width: 3, //边//宽度为5
                            )),
                        labelText: "体重",
                        labelStyle: TextStyle(color: Colors.black38),
                        // helperText: "helperText",
                        // errorText: "errorText",
                        // hintText: "hintText",
                      ),
                    ),
                  ),
                  Padding(
                    padding: const EdgeInsets.only(
                      left: 20,
                      right: 20,
                    ),
                    child: TextField(
                      cursorColor: Color.fromRGBO(116, 208, 217, 1),
                      cursorRadius: Radius.circular(10.0),
                      cursorWidth: 4.0,
                      decoration: InputDecoration(
                        filled: true,
                        fillColor: Color.fromRGBO(242, 242, 242, 0.8),
                        enabledBorder: OutlineInputBorder(
                            /*边角*/
                            borderRadius: BorderRadius.all(
                              Radius.circular(30), //边角为30
                            ),
                            borderSide: BorderSide(
                              color: Color.fromRGBO(1, 1, 1, 0), //边线颜色为黄色
                              width: 3, //边//宽度为5
                            )),

                        focusedBorder: OutlineInputBorder(
                            borderRadius: BorderRadius.all(
                              Radius.circular(30), //边角为30
                            ),
                            borderSide: BorderSide(
                              color: Color.fromRGBO(1, 1, 1, 0), //边线颜色为黄色
                              width: 3, //边//宽度为5
                            )),
                        labelText: "安全距离",
                        labelStyle: TextStyle(color: Colors.black38),
                        // helperText: "helperText",
                        // errorText: "errorText",
                        // hintText: "hintText",
                      ),
                    ),
                  ),
                  Padding(
                    padding: const EdgeInsets.only(top: 30),
                    child: Container(
                      child: Center(
                        child: Text(
                          '添加',
                          style: TextStyle(
                            fontSize: 20,
                            fontWeight: FontWeight.bold,
                            color: Color.fromRGBO(72, 72, 72, 0.8),
                          ),
                        ),
                      ),
                      decoration: new BoxDecoration(
                        color: Color.fromRGBO(255, 205, 216, 1),
                        borderRadius: new BorderRadius.circular((50.0)),
                      ),
                      width: 100,
                      height: 50,
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
